﻿// -------------------------------------------------------------------------
//    @FileName         :    NFDungeonPart.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NFDungeonPart
//
// -------------------------------------------------------------------------

#include "NFDungeonPart.h"

#include "NFPlayer.h"
#include "proto_db.pb.h"

NFDungeonPart::NFDungeonPart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFDungeonPart::~NFDungeonPart()
{
}

int NFDungeonPart::CreateInit()
{
    return 0;
}
    
int NFDungeonPart::ResumeInit()
{
    return 0;
}

int NFDungeonPart::LoadFromDB(const proto_ff::tbRoleDetail *pDBData)
{
    m_stData.FromPb(pDBData->role_play_data().dungeon_data());
    return 0;
}

int NFDungeonPart::InitConfig(proto_ff::tbRoleDetail *pDbData, const RoleOne &stRoleOne)
{
    pDbData->mutable_role_play_data()->mutable_dungeon_data();
    return 0;
}

int NFDungeonPart::SaveDB(proto_ff::tbRoleDetail *pDBData)
{
    m_stData.ToPb(pDBData->mutable_role_play_data()->mutable_dungeon_data());
    return 0;
}

int NFDungeonPart::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    m_stData.ToPb(pCSGetRoleRsp->mutable_dungeon_data());
    return 0;
}

int NFDungeonPart::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    auto pPlayer = GetPlayer();
    CHECK_NULL(0, pPlayer);
    CHECK_NULL(0, pGCCityRoleInfo);
    proto_ff::CityRoleDungeonInfo* pInfo = pGCCityRoleInfo->mutable_dungeon_info();
    pInfo->set_dungeon_id(pPlayer->GetDungeonUID());
    return 0;
}
